import unittest
import requests

class TestIhrmLogin(unittest.TestCase):
    def test01_login_ok(self):
        url="http://ihrm-test.itheima.net/api/sys/login"
        header={"Content-Type":"application/json"}
        json_data={"mobile":"13800000002","password":"123456"}
        resp=requests.post(url=url,headers=header,json=json_data)
        print(resp.json())
        self.assertEqual(200,resp.status_code)
        self.assertEqual(True,resp.json().get("success"))
        self.assertEqual(10000,resp.json().get("code"))
        self.assertIn("操作成功",resp.json().get("message"))
    def test02_mobile(self):
        url="http://ihrm-test.itheima.net/api/sys/login"
        header={"Content-Type":"application/json"}
        json_data={"mobile":"13800000010","password":"123456"}
        resp=requests.post(url=url,headers=header,json=json_data)
        print(resp.json())
        self.assertEqual(200,resp.status_code)
        self.assertEqual(False,resp.json().get("success"))
        self.assertEqual(20001,resp.json().get("code"))
        self.assertIn("用户名或密码错误",resp.json().get("message"))











